<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        textarea {
            padding: 0;
            margin: 0;
            outline: none;
            border: 1px solid pink;
        }

        button {
            outline: none;
            margin: 0;
            /* display: ; */
        }
    </style>
</head>

<body>
    <div>
        <textarea name="" id="" cols="30" rows="10" placeholder="请输入文本"></textarea>
        <button>发布</button>
    </div>
    <script>
        var textarea_1 = document.querySelector("textarea");
        // var txt = textarea_1.value;
        // textarea_1.innerText = null ;
        var button = document.querySelector("button");
        button.onclick = function () {
            var txt = textarea_1.value;
            console.log(txt);
            var ul = document.createElement("ul");
            var divCreate = document.createElement("li");
            var span = document.createElement("span");
            document.body.appendChild(ul);
            ul.appendChild(divCreate);
            divCreate.appendChild(span);
            // divCreate.className = "box";
            // divCreate.value = "txt";
            span.style["display"] = "inline-block";
            span.style["width"] = "200px";
            // divCreate.style["height"] = "50px";
            span.style["background"] = "pink";
            // divCreate.style["border"] = "pink";
            span.style["color"] = "red";
            span.innerText = txt ;
            // divCreate.appendChild(txt);
            
        }

    </script>
</body>

</html>